# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :event_test.py
# @Time      :2025/7/6 15:39
# @Author    :aiyimu

import threading
import time

event = threading.Event()

def waiter():
    print("waiter 等待事件")
    event.wait() # 阻塞直到事件被设置
    print("waiter 收到事件")

def setter():
    print("setter 准备设置事件")
    time.sleep(2)
    event.set()
    print("事件以设置")

t1 = threading.Thread(target=waiter)
t2 = threading.Thread(target=setter)

t1.start()
t2.start()

t1.join()
t2.join()